﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
struct ExerciseInfo
{
    public string Name { get; private set; }
    public double Calories { get; private set; }
    public ExerciseUnit Unit { get; private set; }
    public Dictionary<MuscleGroup, int> MuscleStrain { get; private set; }

    public ExerciseInfo(string path)
        : this(Helpers.ReadFile(path)) {

    }
    public ExerciseInfo(Dictionary<string, string> dict):this() {
        this.MuscleStrain = new Dictionary<MuscleGroup, int>();
        this.Name = dict["name"];
        this.Unit = (ExerciseUnit)Enum.Parse(typeof(ExerciseUnit), dict["unit"], true);  // IgnoreCase?

        if (dict.ContainsKey("calories"))
            this.Calories = double.Parse(dict["calories"]);

        foreach (var muscle in Enum.GetValues(typeof(MuscleGroup)).Cast<MuscleGroup>()) {

            if (dict.ContainsKey(muscle.ToString().ToLower()))
                this.MuscleStrain[muscle] =
                    int.Parse(dict[muscle.ToString().ToLower()]);

            else
                this.MuscleStrain[(MuscleGroup)muscle] = 0;
        }
        // ...

    }
}
